/*
 *    Thing Game Library
 *   Copyright (C)2005 - 2010 Eduardo Nunes Pereira (eduardonunesp at gmail dot com)
 *
 *   This program/library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 *   This program/library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 *    You should have received a copy of the GNU Lesser General Public
 * License along with this program/library ; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "Window.hpp"
#include "Globals.hpp"
#include "Logger.hpp"
#include "Format.hpp"
#include "EventManager.hpp"

std::string Thing::Events::Window::State::stateToString(int state)
{
    switch(state)
    {
        case State::HAS_FOCUS: return "HAS_FOCUS";
        case State::NO_FOCUS : return "NO_FOCUS";
        case State::RESIZING : return "RESIZING";
        case State::QUITTING : return "QUITTING";
        case State::CLEARED  : return "CLEARED";
        default              : return "UNKNOWN";
    }
}

void Thing::Events::Window::clearState()
{
    _window_state = State::CLEARED;
}

void Thing::Events::Window::setWindowState(int state)
{
    if(state < State::__FIRST__ || state > State::__LAST__)
        throw EventsException(EventsException::UNKNOW_EVENT, 
            STG(FMT("Event [%d] is out of range") % state));
    
    MSS_DBG(STG(FMT("Event set to [%s]") % State::stateToString(state)));
    _window_state = state;
}

int Thing::Events::Window::checkWindowState()
{
    return _window_state;
}

